<h3 class="section_header">Details</h3>
<table>
  <tbody>
    <tr>
      <td class="header">Title</td>
      <td>
        <%= result.title %>
        <% if result.content.present? %>
          (<a href="#" data-reveal-id="contents-modal">View Contents</a>)
          <div id="contents-modal" class="reveal-modal" data-reveal>
            <h3>Result Contents</h3>
            <p><%= result.content %></p>
          </div>
        <% end %>
      </td>
    </tr>
    <tr>
      <td class="header">URL</td>
      <td><%= link_to result.url, result.url, data: {confirm: "Are you sure? This will take you to a potentially dangerous site!\n\nURL: " + result.url.to_s}, target:"_blank"  %></td>
    </tr>
    <tr>
      <td class="header">Identified</td>
      <td><%= time_ago_in_words(result.created_at) + " ago" %></td>
    </tr>
    <% if result.metadata.present? %>
      <% (result.metadata.try(:keys) || []).each do |key| %>
        <% begin %>
          <%= render partial: "results/metadata/#{key}_row"  %>
        <% rescue ActionView::MissingTemplate => exception %>

        <% rescue => exception %>

          <% Event.create(action: "Error", source: "results/metadata/#{key}_row" , eventable_type: "Result", eventable_id: result.id, details: "Error while rendering row partial for key: #{key}" + "\n" + "#{exception.message}: #{exception.backtrace}}") %>

        <% end %>
      <% end %>
    <% end %>

  </tbody>
</table>
<% if result.metadata.present? %>
  <% (result.metadata.try(:keys) || []).each do |key| %>
    <% begin %>
      <%= render partial: "results/metadata/#{key}_details"  %>
    <% rescue ActionView::MissingTemplate => exception %>

    <% rescue => exception %>
      <% Event.create(action: "Error", source: "results/metadata/#{key}_details" , eventable_type: "Result", eventable_id: result.id, details: "Error while rendering details partial for key: #{key}" + "\n" + "#{exception.message}: #{exception.backtrace}}") %>
    <% end %>
  <% end %>
<% end %>
</br>
